package com.jml.jdk8.stream;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Test;

/**
 * @author:jml
 * @date: 2020/2/10 0010 10:47
 * @description：
 */
public class Test001 {

    @Test
    public void tt(){
        /**
         * Arrays.asList生成的集合不可进行删除操作
         * 流生成的数组可以进行删除操作
         */
        List<String> objects = Stream.of("1","2","3").collect(Collectors.toList());
        List<String> objects1 = Stream.of("4","5","6","3").collect(Collectors.toList());
        boolean b = objects1.removeAll(objects);
        System.out.println(objects);
        System.out.println(objects1);
    }

    @Test
    public void tt1(){
        /**
         * Collectors.toCollection指定返回类型
         */
        List<String> list = Stream.of("1","2","3","2","3").collect(Collectors.toList());
        HashSet<String> hashSet = list.stream().collect(Collectors.toCollection(HashSet::new));
        System.out.println(hashSet);
    }


}
